// 页面主逻辑入口
require(["../lib/js/jquery-1.12.4.min"], function () {
  requirejs([
    "public/business/headAndFoot", 
    "layer",
    "laydate",
    "config/path",
  ], function (headAndFoot, layer, laydate, pathObj) {
    // layer弹窗配置基础路径
    layer.config({
      path: '../../lib/',
      extend: 'jigou/layer.css', //加载新皮肤
      skin: 'layer-ext-jigou' //一旦设定，所有弹层风格都采用此主题。
    });

    // laydate配置基础路径
    laydate.path = "../../lib/js/laydate/";

    // 针对对应类型页面做初始化
    loginIn();
    headAndFoot(function () {
      route();
    });
  });
});

// 获取机构基本信息（从浏览器的url里面获取）
function loginIn() {
  var _search = window.location.search.substring(1);

  if (!_search.length) return;
  _search = _search.split("&");

  $.each(_search, function (i, e) {
    var _e = e.split("=");

    // 会员id
    if (_e[0] == "member_id") {
      localStorage.member_id = _e[1];
      return true;
    }

    // 登录令牌
    if (_e[0] == "token") {
      localStorage.token = _e[1];
      return true;
    }

    // 商家id
    if (_e[0] == "merchant_id") {
      localStorage.merchant_id = _e[1];
      return true;
    }

    // 是否是演示账号-用来判断是否放出静态页面
    localStorage.demo_account = false;
    if (_e[0] == "demo_account") {
      var sStr = _e[1];
      if(sStr == "b326b5062b2f0e69046810717534cb09"){
        localStorage.demo_account = true;
      }
      return true;
    }
  });
}

// 页面入口配置
function route() {
  var pathname = window.location.pathname;

  // 首页
  if (pathname.match("/view/index.html") || pathname == "/") {
    requirejs(["page-Index/entry-index"], function (init) {
      init();
    });
    return;
  }

  
}

